﻿using System.Drawing;

namespace RoboRallyAPI
{
	/// <summary>
	/// The map of the game.
	/// </summary>
	public class GameMap
	{

		/// <summary>
		/// Create an empty map (no squares).
		/// </summary>
		protected GameMap()
		{
		}

		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="src">Initialize with the values in this object.</param>
		public GameMap(GameMap src)
		{
			Squares = new MapSquare[src.Squares.Length][];
			for (int x = 0; x < src.Squares.Length; x++)
			{
				Squares[x] = new MapSquare[src.Squares[x].Length];
				for (int y = 0; y < src.Squares[x].Length; y++)
					Squares[x][y] = new MapSquare(src.Squares[x][y]);
			}
			Flags = new Point[src.Flags.Length];
			for (int ind = 0; ind < src.Flags.Length; ind++)
				Flags[ind] = src.Flags[ind];
		}

		/// <summary>
		/// The width of the map. Units are squares.
		/// </summary>
		public int Width
		{
			get { return Squares.Length; }
		}

		/// <summary>
		/// The height of the map. Units are squares.
		/// </summary>
		public int Height
		{
			get { return Squares[0].Length; }
		}

		/// <summary>
		/// The map squares. This is in the format [x][y].
		/// </summary>
		public MapSquare [][] Squares { get; protected set; }

		/// <summary>
		/// Location (map squares) of the flags in order.
		/// </summary>
		public Point[] Flags { get; protected set; }

		/// <summary>
		/// Get a specific map square.
		/// </summary>
		/// <param name="location">The x, y point for the square desired.</param>
		/// <returns>The requested square.</returns>
		public MapSquare GetSquare(Point location)
		{
			return Squares[location.X][location.Y];
		}
	}
}
